#include "common.h"

void duplicateZeros(vector<int>& arr)
{
	int n = arr.size();
	int start = 0;
	int end = n - 1;
	int m = 0;
	for (; start < n; start++)
	{
		m++;
		if (arr[start] == 0)
			m++;
		if (m >= n)
			break;
	}
	if (m > n)
	{
		arr[n - 1] = 0;
		start--;
		end--;
	}
	for (; start >= 0; start--, end--)
	{
		arr[end] = arr[start];
		if (arr[start] == 0)
		{
			end--;
			arr[end] = 0;
		}
	}
}